kind: Deployment
apiVersion: apps/v1
metadata:
  name: todo
  labels:
    app: todo
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 30%
      maxSurge: 50%
  selector:
    matchLabels:
      app: todo
  template:
    metadata:
      labels:
        app: todo
    spec:
      containers:
      - name: todo
        image: bookofkubernetes/todo:{{ todo_version }}
        env:
        - name: NODE_ENV
          value: production
        - name: PREFIX
          value: {{ todo_prefix }}
        - name: PGHOST
          value: todo-db
        - name: PGDATABASE
          value: todo
{% if todo_postgres_operator %}
        - name: PGUSER
          valueFrom:
            secretKeyRef:
              name: todo.todo-db.credentials.postgresql.acid.zalan.do
              key: username
              optional: false
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              name: todo.todo-db.credentials.postgresql.acid.zalan.do
              key: password
              optional: false
{% else %}
        - name: PGUSER
          valueFrom:
            secretKeyRef:
              name: todo-db
              key: POSTGRES_USER
              optional: false
        - name: PGPASSWORD
          valueFrom:
            secretKeyRef:
              name: todo-db
              key: POSTGRES_PASSWORD
              optional: false
{% endif %}
        resources:
          requests:
            memory: "128Mi"
            cpu: "50m"
          limits:
            memory: "128Mi"
            cpu: "50m"
        ports:
        - name: web
          containerPort: 5000